package com.nbicc.anon.newpic.controller;

import com.nbicc.newpic.service.INewPicService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@Api(value = "新闻图片(匿名)" , description = "对发布的新闻图片控制")
@RestController
@RequestMapping(value = "/anon/newPic")
public class AnonNewPicController {

    @Resource(name = "AnonNewPicServiceImpl")
    private INewPicService newPicService;


    @ApiOperation(value = "新闻图片获取" , notes = "图片id")
    @GetMapping("/{id}")
    public void downloadFile(
            @PathVariable("id") long id,
            HttpServletRequest request,
            HttpServletResponse response) throws IOException {
        response.setHeader("Expires","Mon, 23 Nov 2018 02:16:15 GMT");
        response.setHeader("Cache-Control","max-age=31536000");
        newPicService.downloadFile(request , response , id);
    }

    public static void main(String[] args) {
    }

}
